<template>
  <div>
    <v-chart class="chart" :option="option" />
    <v-chart class="chart" :option="option1" />
  </div>
</template>

<script setup>
import VChart from "vue-echarts";
const data = ref([
  { value: 50, date: '2024-01-01' },
  { value: 60, date: '2024-01-02' },
  { value: 20, date: '2024-01-03' },
  { value: 30, date: '2024-01-04' },
  { value: 70, date: '2024-01-05' },
])

setInterval(() => {
  data.value = data.value.map(item => ({
    ...item,
    value: Math.random() * 100
  }))
}, 1000)

let option = {
  title: {
    text: 'Referer of a Website',
    subtext: 'Fake Data',
    left: 'center'
  },
  tooltip: {
    trigger: 'item'
  },
  legend: {
    orient: 'vertical',
    left: 'left'
  },
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: '50%',
      data: [
        { value: 1048, name: 'Search Engine' },
        { value: 735, name: 'Direct' },
        { value: 580, name: 'Email' },
        { value: 484, name: 'Union Ads' },
        { value: 300, name: 'Video Ads' }
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }
  ]
};

let option1 = computed(() => {
  return {
    xAxis: {
      data: ['2017-10-24', '2017-10-25', '2017-10-26', '2017-10-27']
    },
    yAxis: {},
    series: [
      {
        type: 'candlestick',
        data: [
          [20, 34, 10, 38],
          [40, 35, 30, 50],
          [31, 38, 33, 44],
          [38, 15, 5, 42]
        ]
      }
    ]
  };
})

</script>

<style scoped>
.chart {
  height: 400px;
}
</style>